package org.example.travel_web.controller.admin;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.example.travel_web.dto.login.AdmRegisterReq;
import org.example.travel_web.dto.login.LoginReq;
import org.example.travel_web.dto.login.LoginResult;
import org.example.travel_web.service.SysUserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/login")
@Tag(name = "管理员登录")
public class LoginController {

    @Resource
    private SysUserService sysUserService;

    @PostMapping
    @Operation(summary = "用户登录")
    public LoginResult login(@Valid LoginReq req) {
        return sysUserService.login(req);
    }

    @PostMapping("/register")
    @Operation(summary = "用户注册")
    public void register(@Valid AdmRegisterReq req) {
        sysUserService.register(req);
    }
}
